from typing import Optional


class Solution:
    def isSymmetric(self, root: Optional[TreeNode]) -> bool:
        l = deque([root])
        r = deque([root])
        while l and r:
            lc = l.popleft()
            rc = r.popleft()
            if lc != rc: return False
            if lc is None and rc is None: continue
            l.append(lc.left)
            l.append(lc.right)
            r.append(rc.right)
            r.append(rc.left)
        return True
